const ExtractTextPlugin = require('extract-text-webpack-plugin');

// Create multiple instances
const extractLESS = new ExtractTextPlugin(`css/[name].min.css`);

const webpack = require('webpack');

module.exports = {
	entry:{
        'app':'./src/js/app.js',
        'layout':'./src/js/layout.js',
        'index':'./src/js/index.js'
    },
	output:{
		filename:'js/[name].min.js',
		path:`${__dirname}/build`
	},
	module:{
		rules:[
            {
                test: /\.js$/,
                use: [
                    {
                        loader: 'babel-loader',
                        options: {
                            presets: ['es2015'],
                            plugins: ['transform-object-rest-spread']
                        }
                    }
                ],
                exclude: /node_modules/
            },
            {
                test:/\.less$/,
                use:extractLESS.extract([ 'css-loader?minimize', 'postcss-loader','less-loader' ])
            }
        ]
	},
    resolve:{
        alias:{
            vue:"vue/dist/vue.min.js"
        }
    },
    plugins: [
        extractLESS,
        new webpack.ProvidePlugin({
            ENV: `${__dirname}/env/${process.env.NODE_ENV || "dev"}`
        })
    ]
}
